package com.java.util;

import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Date;
import java.util.Random;

public class RandomUtil {
    private static final Random r = new Random();
    private static final String[] FIRST_NAME = new String[]{"赵", "钱", "孙", "李", "周", "吴", "郑", "王"};
    private static final String[] LAST_NAME = new String[]{"一", "二", "三", "四", "五", "六", "七", "八", "九", "十"};
    private static final char[] SECOND_PHONE_NUM = new char[]{'3', '4', '5', '7', '8'};
    private static final String[] COMPANY = new String[]{
            "安能快递", "安能物流", "澳大利亚邮政", "阿根廷邮政", "爱沙尼亚邮政", "阿联酋邮政", "奥地利邮政", "阿尔巴尼亚邮政", "Aramex", "巴西邮政", "比利时邮政", "百世快运", "波兰邮政", "白俄罗斯邮政", "保加利亚邮政", "巴基斯坦邮政", "百福东方",
            "COE", "传喜物流", "德邦快递", "大田物流", "递四方", "DHL德国", "DHL全球", "DHL中国", "EMS", "EMS国际", "EMS经济快递", "FedEx中国", "晟邦物流", "城市100", "City-Link", "芝麻开门", "中国邮政", "智利邮政", "京广速递",
            "FedEx国际", "FedEx美国", "飞豹快递", "凡宇快递", "飞远配送", "飞远(爱彼西)", "法国邮政", "芬兰邮政", "国通快递", "postco", "百世快递", "恒路物流", "黄马甲配送", "黑猫宅急便", "华企快运", "韩国邮政", "佳吉快运", "京东快递",
            "日本邮政", "筋斗云物流", "捷克邮政", "嘉里大通", "加运美", "快捷快递", "跨越速运", "克罗地亚邮政", "联昊通", "龙邦速递", "黎巴嫩邮政", "民航快递", "秘鲁邮政", "毛里求斯邮政", "马耳他邮政", "摩尔多瓦邮政", "马其顿邮政", "民邦快递",
            "挪威邮政", "南非邮政", "OnTrac", "葡萄牙邮政", "全峰快递", "全一快递", "如风达", "申通快递", "顺丰速运", "速尔快递", "盛丰物流", "圣安物流", "盛辉物流", "瑞士邮政", "苏宁快递", "斯洛伐克邮政", "沙特邮政", "斯洛文尼亚邮政", "佳怡物流",
            "塞尔维亚邮政", "天天快递", "天地华宇", "土耳其邮政", "泰国邮政", "TNT", "UPS", "USPS", "万象物流", "乌克兰邮政", "万家物流", "信丰物流", "新邦物流", "西班牙邮政", "匈牙利邮政", "圆通速递", "韵达快递", "明亮物流", "包裹信件",
            "优速物流", "银捷速递", "远成物流", "运通中港快递", "邮政国内小包", "英国皇家邮政", "意大利邮政", "印度邮政", "亚美尼亚邮政", "越丰物流", "亚风速递", "邮政国际包裹", "中通快递", "宅急送", "中铁物流", "增益速递", "中铁快运", "中速快递"};

    public static String generateCode() {
        return "" + (r.nextInt(89999999) + 10000000);
    }

    public static String generateNumber() {
        return (r.nextInt(20) * 100 + 1030 + r.nextInt(20)) + "-" + String.format("%04d", r.nextInt(9999)) + "-" + String.format("%08d", r.nextInt(99999999));
    }

    public static String generateName() {
        return FIRST_NAME[r.nextInt(8)] + LAST_NAME[r.nextInt(10)] + LAST_NAME[r.nextInt(10)];
    }

    public static String generatePhone() {
        return "1" + SECOND_PHONE_NUM[r.nextInt(4)] + String.format("%09d", r.nextInt(999999999));
    }

    public static String generatePassword() {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 20; i++) {
            sb.append((char) (r.nextInt(75) + 48));
        }
        return sb.toString();
    }

    public static String generateCompany() {
        return COMPANY[r.nextInt(127)];
    }

    public static Timestamp generateTime() {
        return new Timestamp(new Date().getTime() - r.nextInt(999999999));
    }

    public static int gen(int bound) {
        return r.nextInt(bound);
    }

    public static String genStr(int digit) {
        if (digit < 1 || digit > 20) return "";
        long i = 1L;
        for (int j = 0; j < digit; j++) {
            i *= 10;
        }
        return String.format("%0" + digit + 'd', Math.abs(r.nextLong() % i));
    }

}
